package meconsea.life.note.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import meconsea.life.sys.entity.AbsEntity;

import org.hibernate.annotations.Type;

@Entity
@Table(name="NOTE_LIST")
@NamedQueries({
	@NamedQuery(name=NoteList.NOTE_LIST_FIND_PUBLIC,query="SELECT O.id,O.userId,O.isPublic,O.title,O.summany,'' IS O.content,O.keywords," +
			"O.noteCls,O.readSum,O.commentSum,O.isCommend,O.createdAt,O.changedAt,O.editPwd from NoteList O where O.isPublic=:isPublic order by O.createdAt"),
	@NamedQuery(name=NoteList.NOTE_LIST_FIND_PUBLIC_COUNT,query="SELECT COUNT(O.id) FROM NoteList O where O.isPublic=:isPublic"),
	@NamedQuery(name=NoteList.NOTE_LIST_FIND_PUBLIC_USER,query="SELECT O.id,O.userId,O.isPublic,O.title,O.summany,'' IS O.content,O.keywords," +
			"O.noteCls,O.readSum,O.commentSum,O.isCommend,O.createdAt,O.changedAt,O.editPwd from NoteList O where O.isPublic=:isPublic and O.userId = :userId order by O.createdAt"),
	@NamedQuery(name=NoteList.NOTE_LIST_FIND_PUBLIC_USER_COUNT,query="SELECT COUNT(O.id) FROM NoteList O where  O.isPublic=:isPublic and O.userId = :userId"),
	@NamedQuery(name=NoteList.NOTE_LIST_FIND_CLS_PUBLIC,query="SELECT O.id,O.userId,O.isPublic,O.title,O.summany,'' IS O.content,O.keywords," +
			"O.noteCls,O.readSum,O.commentSum,O.isCommend,O.createdAt,O.changedAt,O.editPwd from NoteList O where O.isPublic=:isPublic AND O.noteCls=:noteCls order by O.createdAt"),
	@NamedQuery(name=NoteList.NOTE_LIST_FIND_CLS_PUBLIC_COUNT,query="SELECT COUNT(O.id) from NoteList O where O.isPublic=:isPublic AND O.noteCls=:noteCls "),
	@NamedQuery(name=NoteList.NOTE_LIST_FIND_CLS_USER,query="SELECT O.id,O.userId,O.isPublic,O.title,O.summany,'' IS O.content,O.keywords," +
			"O.noteCls,O.readSum,O.commentSum,O.isCommend,O.createdAt,O.changedAt,O.editPwd from NoteList O where O.userId=:userId AND O.noteCls=:noteCls order by O.createdAt"),
	@NamedQuery(name=NoteList.NOTE_LIST_FIND_CLS_USER_COUNT,query="SELECT COUNT(O.id) from NoteList O where O.userId=:userId AND O.noteCls=:noteCls"),
	@NamedQuery(name=NoteList.NOTE_LIST_FIND_CLS_USER_PUBLIC,query="SELECT O.id,O.userId,O.isPublic,O.title,O.summany,'' IS O.content,O.keywords," +
			"O.noteCls,O.readSum,O.commentSum,O.isCommend,O.createdAt,O.changedAt,O.editPwd from NoteList O where O.userId=:userId AND O.noteCls=:noteCls AND O.isPublic=:isPublic order by O.createdAt"),
	@NamedQuery(name=NoteList.NOTE_LIST_FIND_CLS_USER_PUBLIC_COUNT,query="SELECT COUNT(O.id) from NoteList O where O.userId=:userId AND O.noteCls=:noteCls AND O.isPublic=:isPublic order by O.createdAt")
})
public class NoteList extends AbsEntity {
	//获取全部公开的日记
	public final static String NOTE_LIST_FIND_PUBLIC = "note_list_find_public";
	public final static String NOTE_LIST_FIND_PUBLIC_COUNT = "note_list_find_public_count";
	
	//根据作者获取其某种公开程度的模板
	public final static String NOTE_LIST_FIND_PUBLIC_USER = "note_list_find_public_user";
	public final static String NOTE_LIST_FIND_PUBLIC_USER_COUNT = "note_list_find_public_user_count";
	
	//根据类别、公开来查询
	public final static String NOTE_LIST_FIND_CLS_PUBLIC = "note_list_find_cls_public";
	public final static String NOTE_LIST_FIND_CLS_PUBLIC_COUNT = "note_list_find_cls_public_count";
	
	//根据类别和作者
	public final static String NOTE_LIST_FIND_CLS_USER = "note_list_find_cls_user";
	public final static String NOTE_LIST_FIND_CLS_USER_COUNT="note_list_find_cls_user_count";
	
	//根据作者、类别、公开程度
	public final static String NOTE_LIST_FIND_CLS_USER_PUBLIC="note_list_find_cls_user_public";
	public final static String NOTE_LIST_FIND_CLS_USER_PUBLIC_COUNT = "note_list_find_cls_user_public_count";
	
	@Column(name="userid",length=64)
	private String userId;
	
	@Column(name="isPublic")
	@Type(type="integer")
	private Integer isPublic;
	
	@Column(name="title", length=256)
	private String title;
	

	@Column(name="summany",length=512)
	private String summany;
	
	@Column(name="content")
	@Type(type="text")
	private String content;
	
	@Column(name="keywords",length=512)
	private String keywords;
	
	@Column(name="notecls",length=256)
	private String noteCls;
	
	@Column(name="readSum")
	@Type(type="integer")
	private Integer readSum=0;
	
	@Column(name="commentSum")
	@Type(type="integer")
	private Integer commentSum=0;
	
	@Column(name="isCommend")
	@Type(type="integer")
	private Integer isCommend=0;
	
	@Column(name="editPwd",length=128)
	private String editPwd;
	
	public String getEditPwd() {
		return editPwd;
	}

	public void setEditPwd(String editPwd) {
		this.editPwd = editPwd;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public Integer getIsPublic() {
		return isPublic;
	}

	public void setIsPublic(Integer isPublic) {
		this.isPublic = isPublic;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getSummany() {
		return summany;
	}

	public void setSummany(String summany) {
		this.summany = summany;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getKeywords() {
		return keywords;
	}

	public void setKeywords(String keywords) {
		this.keywords = keywords;
	}

	public String getNoteCls() {
		return noteCls;
	}

	public void setNoteCls(String noteCls) {
		this.noteCls = noteCls;
	}

	public Integer getReadSum() {
		return readSum;
	}

	public void setReadSum(Integer readSum) {
		this.readSum = readSum;
	}

	public Integer getCommentSum() {
		return commentSum;
	}

	public void setCommentSum(Integer commentSum) {
		this.commentSum = commentSum;
	}

	public Integer getIsCommend() {
		return isCommend;
	}

	public void setIsCommend(Integer isCommend) {
		this.isCommend = isCommend;
	}

}
